import { getToken, setToken, delToken } from '@/utils/storage'

export default {
  namespaced: true,
  state() {
    return {
      token: getToken()
    }
  },

  mutations: {
    // login 页面传过来 token 存储：
    storageToken(state, payload) {
      state.token = payload

      // 本地也要存一份
      setToken(payload)
    },

    // layout 页面中退出登录，清除 token
    clearToken(state) {
      state.token = ''
      delToken()
    }
  },

  actions: {},

  getters: {}
}